<template>
  <view class="info">
    <view class="infoBox">
      <view class="infoPrice">
        <view class="let">
          <view class="active">
            <view class="s1">{{ getPrice(data.price)[0] }}</view>
            <view>.{{ getPrice(data.price)[1] }}</view>
          </view>
        </view>
        <view class="rig"> {{ data.order_num || 0 }} 人选择 </view>
      </view>
      <view class="infoHeader">
        <view class="name">{{ data.name }}</view>

        <view class="des">
          {{ data.desc.join("·") }}
        </view>
      </view>
    </view>

    <view class="step">
      <numberStep
        :value="num"
        :min="1"
        @input="(e) => Emit.$emit('handle', 'changeNum', e)"
      ></numberStep>
    </view>

    <view class="tag" v-if="data.service">
      <view class="tagItem" v-for="(item, i) of data.service" :key="i">
        <i class="iconfont icon-success"></i>
        <view class="txt">{{ item }}</view>
      </view>
    </view>
  </view>
</template>

<script>
import numberStep from "@/components/cyyUi/numberStep/index.vue";

export default {
  components: {
    numberStep,
  },

  props: {
    num: {
      type: Number,
      default: 1,
    },
    data: {
      type: Object,
      default() {
        return null;
      },
    },
  },

  computed: {
    getPrice() {
      return (price) => {
        return price.split(".") || ["0", "00"];
      };
    },

    hasShowTag() {
      return (str, key) => {
        return str.indexOf(key) !== -1;
      };
    },
  },

  methods: {},
};
</script>

<style lang="less" scoped>
.info {
  margin-bottom: 24rpx;
  background: #fff;
  font-size: 24rpx;
}

.infoBox {
  padding: 15rpx 24rpx 30rpx;
}

.infoPrice {
  display: flex;
  align-items: center;
  align-items: flex-end;

  .let {
    flex: 1;
    overflow: hidden;

    .active {
      display: flex;
      align-items: flex-end;
      color: #f8260a;
      font-size: 34rpx;

      &:before {
        content: "¥";
      }

      .s1 {
        font-size: 56rpx;
        font-weight: bold;
        line-height: 1.1;
      }
    }
  }

  .rig {
    margin-left: 10rpx;
    color: #8c8c8c;
    font-size: 22rpx;
  }
}

.infoHeader {
  .name {
    padding: 12rpx 0;
    font-size: 32rpx;
    font-weight: bold;
    color: #262626;
  }

  .des {
    color: #8c8c8c;
    font-size: 24rpx;
  }
}

.tag {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  color: #8c8c8c;
  background: #fbfcfb;
  font-size: 22rpx;
  padding: 24rpx 24rpx 10rpx;

  .tagItem {
    display: flex;
    align-items: center;
    margin-bottom: 14rpx;

    .txt {
      padding: 0 20rpx 0 8rpx;
    }
  }

  .iconfont {
    font-size: 22rpx;
  }
}

.step {
  padding: 0 20rpx 30rpx 0;
  display: flex;
  justify-content: flex-end;
}
</style>
